package com.acme.bankapp.domain.bank;

/**
 * Class implements Checking type of Account with overdraft possibility
 * @author Vasilyev Anton
 *
 */
public class CheckingAccount implements Account {
	private double balance;
	private double overdraft;

	@Override
	public double getBalance() {
		return this.balance;
	}
	
	public double maxAmountToWithdraw() {
		return this.balance + this.overdraft;
	}

	@Override
	public void deposite(double amount) {
		this.balance += amount;
	}

	@Override
	public void withdraw(double amount) {
		if (this.balance >= amount) {
			this.balance -= amount;
		} else if (this.balance + this.overdraft >= amount) {
			this.overdraft -= amount - this.balance;
			this.balance = 0;
		}
			
	}

}
